import React from "react";
import { useNavigate, useLocation } from "react-router-dom";

import "./index.css";
import submitImg from "./img/successpay.png";

export default function PaySuccess() {
  const navigate = useNavigate();

  const loca = useLocation();

  // 回购物车
  function backshoppingCart() {
    navigate("/home/shoppingCart");
  }
  // 查看订单
  function lookOrder() {
    console.log(loca);
    if (loca.state.shops) {
      navigate("/home/person/myorder/allorder");
    } else {
      navigate("/home/person/scoreorder");
    }
  }
  function backIndex() {
    navigate("/home");
  }
  return (
    <div id="tyc_pay_success">
      <ul>
        <li className="tyc_fristli" onClick={backshoppingCart}>
          我的购物车
        </li>
        <li>确认订单信息</li>
        <li className="tyc_lastli">订单提交成功</li>
      </ul>

      <div id="tyc_pay_success_cart">
        <div className="tyc_payseccuss_img">
          <img src={submitImg} alt="" />
          <p>支付成功</p>
        </div>
        <div className="tyc_paysuccess_btns">
          <button onClick={lookOrder}>查看订单</button>
          <button onClick={backIndex}>返回首页</button>
          <p>
            <strong>订单编号：</strong>
            <span>20150901144912ah4941</span>
          </p>
        </div>
      </div>
    </div>
  );
}
